package cn.kow.kmall.controller.member;

import cn.kow.kmall.controller.BaseController;
import cn.kow.kmall.core.response.KmallResult;
import cn.kow.kmall.pojo.dto.UserQueryDTO;
import cn.kow.kmall.pojo.entity.User;
import cn.kow.kmall.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: lijun
 * @Description:
 * @Date: Created in 2020-04-28 16:35
 * @Modified By:
 */
@Slf4j
@RestController
@RequestMapping("/member")
public class MemberController extends BaseController {

    @Autowired
    private UserService userService;

    @PostMapping(value = "/list")
    public KmallResult list(@RequestBody UserQueryDTO queryDTO) {
        Page<User> page = userService.listByPage(queryDTO);
        return KmallResult.success().put("rows", page.getContent())
                .put("total", page.getTotalElements());
    }
}
